package com.xxd.spring.boot.demo.wubolin.controller;


import com.xxd.spring.boot.demo.wubolin.Result;
import com.xxd.spring.boot.demo.wubolin.entity.StudentCurriculumFraction;
import com.xxd.spring.boot.demo.wubolin.exception.MyException;
import com.xxd.spring.boot.demo.wubolin.service.StudentCurriculumFractionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/studentcurriculumfraction")
public class StudentCurriculumFractionController {

    @Autowired
    private StudentCurriculumFractionService studentCurriculumFractionService;

    @RequestMapping("/add")
    public Result add(@RequestBody StudentCurriculumFraction studentCurriculumFraction) throws MyException {
        studentCurriculumFractionService.add(studentCurriculumFraction);
        return new Result().success();
    }

    @RequestMapping("/update")
    public Result update(@RequestBody StudentCurriculumFraction studentCurriculumFraction) throws MyException {
        studentCurriculumFractionService.update(studentCurriculumFraction);
        return new Result().success();
    }

    @RequestMapping("/delete/{id}")
    public Result detele(@PathVariable("id") Integer id) throws MyException {
        studentCurriculumFractionService.delete(id);
        return  new Result().success();
    }

    @RequestMapping("/all")
    public Result all(){
        List<StudentCurriculumFraction> list = studentCurriculumFractionService.all();
        return new Result().success().setData(list);
    }
}
